<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>管理后台</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="images/favicon.ico">
    <link rel="stylesheet" href="/wpui-admin/wp-ewallet-admin/static//plugin/layuimini/lib/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/wpui-admin/wp-ewallet-admin/static//plugin/layuimini/css/layuimini.css" media="all">
    <link rel="stylesheet" href="/wpui-admin/wp-ewallet-admin/static//plugin/layuimini/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style id="layuimini-bg-color">
    </style>
    <style>
        .layui-layout-admin .layui-header{
            border-bottom: 1px solid #dddddd;
            box-shadow: 0px 1px 2px #dddddd;
        }

        .layui-layout-right{
            right: 25px;
        }

        .layui-layout-right a{
            color: #888888 !important;
        }

        .layuimini-setting > .layui-nav-more {
            color: #888888;
            border-color: #888888  transparent transparent;
        }

        .layui-nav .layui-nav-more{
            color: #888888;
            border-color: #888888  transparent transparent;
        }

        .layui-layout-admin .layui-logo{
            width: 80px;
            height: 50px;
        }

        .logo-title{
            position: absolute;
            line-height: 60px;
            font-size: 18px;
            font-weight: bold;
            color: #569CF5;
            left: 55px;
        }

    </style>
</head>
<body class="layui-layout-body layuimini-all">
<div id="container" class="layui-layout layui-layout-admin">

    <div class="layui-header header">
        <div class="layui-logo"></div>
        <div class="logo-title">乐居电子商城管理平台</div>
        <!--<a>
            <div class="layuimini-tool"><i title="展开" class="fa fa-outdent" data-side-fold="1"></i></div>
        </a>-->

        <ul class="layui-nav layui-layout-left layui-header-menu layui-header-pc-menu mobile layui-hide-xs">
        </ul>
        <ul class="layui-nav layui-layout-left layui-header-menu mobile layui-hide-sm">
            <li class="layui-nav-item">
                <a href="javascript:;"><i class="fa fa-list-ul"></i> 选择模块</a>
                <dl class="layui-nav-child layui-header-mini-menu">
                </dl>
            </li>
        </ul>

        <ul id="topNav" class="layui-nav layui-layout-right">

        </ul>

        <script id="topNavTpl" type="text/html">
            <li class="layui-nav-item">
                <a href="javascript:;" data-refresh="刷新"><i class="fa fa-refresh"></i></a>
            </li>
            <li class="layui-nav-item layuimini-setting">
                <a href="javascript:;">
                    <i class="layui-icon layui-icon-username" style="color: #61B3FF;"></i>
                    <span>{{user.account}}</span>
                </a>
                <dl class="layui-nav-child">
                    <!--<dd>
                        <a href="javascript:;" data-iframe-tab="page/user-setting.html" data-title="基本资料" data-icon="fa fa-gears">基本资料</a>
                    </dd>
                    <dd>
                        <a href="javascript:;" data-iframe-tab="page/user-password.html" data-title="修改密码" data-icon="fa fa-gears">修改密码</a>
                    </dd>-->
                    <dd>
                        <a id="logoutId" href="javascript:;" class="login-out">退出登录</a>
                    </dd>
                </dl>
            </li>
            <li class="layui-nav-item layuimini-select-bgcolor mobile layui-hide-xs">
                <!--<a href="javascript:;" data-bgcolor="配色方案"><i class="fa fa-ellipsis-v"></i></a>-->
            </li>
        </script>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll layui-left-menu">
        </div>
    </div>

    <div class="layui-body">
        <div class="layui-tab" lay-filter="layuiminiTab" id="top_tabs_box">
            <!-- 注释掉首页TAB标题 -->
            <ul class="layui-tab-title" id="top_tabs">
                <li class="layui-this" id="layuiminiHomeTabId" lay-id=""></li>
            </ul>
            <ul id="tabNav" class="layui-nav closeBox"></ul>

            <script id="tabNavTpl" type="text/html">
                <li class="layui-nav-item">
                    <a href="javascript:;"> <i class="fa fa-dot-circle-o"></i> 页面操作</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" data-page-close="other"><i class="fa fa-window-close"></i> 关闭其他</a></dd>
                        <dd><a href="javascript:;" data-page-close="all"><i class="fa fa-window-close-o"></i> 关闭全部</a></dd>
                    </dl>
                </li>
            </script>


            <div class="layui-tab-content clildFrame">
                <!-- 注释掉首页TAB -->
                <div id="layuiminiHomeTabIframe" class="layui-tab-item layui-show"></div>
            </div>
        </div>
    </div>
</div>

<script src="/wpui-admin/wp-ewallet-admin/static/js/jquery-3.4.1.min.js"></script>
<script src="/wpui-admin/wp-ewallet-admin/static/plugin/layuimini/lib/layui/layui.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/module/index/config.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/global/wp.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/static/js/vue.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/static/js/vue-i18n.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/global/wp-i18n.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/global/wp-project.js" charset="utf-8"></script>

<script>
    // 首页模块加载模块
    layui.use(['element', 'layer', 'layuimini'], function () {
        var $ = layui.jquery,
            element = layui.element,
            layer = layui.layer;

        var vm = new Vue({
            el: '#container',
            i18n: wp.i18n(),
            data: {
                user:{}
            },
            mounted: function () {
                var that = this;
                //获取用户名和职称
                var user =  wp.getUser();
                that.user = user;
                if(user == null) {
                    window.location.href = '/login.html';
                };

                // 创建唯一ID，用于判断重复登录
                that.createUUID();
                // 获取menu列表
                wp.httpGet({
                    url: wp.url('/wp/ewallet/upms/menu/list'),
                    success:function(data){
                        var menuData = data.dataBody;
                        var mainData = {
                            "clearInfo": {
                                "clearUrl": "api/clear.json"
                            },
                            "homeInfo": {
                                "title": "待处理申请单",
                                "icon": "layui-icon iconxiangmuguanli",
                                "href": "/wpui-admin/wp-ewallet-admin/module/wallet/wallet-apply.html"
                            },
                            "logoInfo": {
                                "title": "LayuiMini",
                                "image": "wpui-admin/wp-ewallet-admin/static/image/LOGO.png",
                                "href": ""
                            },
                            "menuInfo": {
                                parent:{
                                    "title": "看不见的菜单",
                                    "href": "",
                                    "icon": "fa fa-home",
                                    "target": "_self",
                                    "child": []
                                }
                            }
                        }

                        for(var i = 0 ; i < menuData.length;i++){
                            //mainData.menuInfo.parent["index" + i] = menuData[i];
                            mainData.menuInfo.parent.child[i] = menuData[i];
                        }

                        // 手动加两个菜单
                        var menuIndex = mainData.menuInfo.parent.child.length;
                        /*mainData.menuInfo.parent.child[menuIndex] = {
                            "title": "归集查询",
                            "href": "/wpui-admin/wp-ewallet-admin/module/wallet/wallet-collection-query.html",
                            "icon": "fa fa-tachometer",
                            "target": "_self"
                        };

                        mainData.menuInfo.parent.child[menuIndex + 1] = {
                            "title": "归集查询详情",
                            "href": "/wpui-admin/wp-ewallet-admin/module/wallet/wallet-collection-detail.html",
                            "icon": "fa fa-tachometer",
                            "target": "_self"
                        };*/

                        /*mainData.menuInfo.parent.child[menuIndex + 2] = {
                            "title": "转账记录查询",
                            "href": "/wpui-admin/wp-ewallet-admin/module/wallet/wallet-transfer-query.html",
                            "icon": "fa fa-tachometer",
                            "target": "_self"
                        };

                        mainData.menuInfo.parent.child[menuIndex + 3] = {
                            "title": "用户信息查询",
                            "href": "/wpui-admin/wp-ewallet-admin/module/upms/user/user-query.html",
                            "icon": "fa fa-tachometer",
                            "target": "_self"
                        };

                        mainData.menuInfo.parent.child[menuIndex + 4] = {
                            "title": "手续费统计",
                            "href": "/wpui-admin/wp-ewallet-admin/module/wallet/wallet-fee-query.html",
                            "icon": "fa fa-tachometer",
                            "target": "_self"
                        };*/


                        that.$nextTick(function () {
                            layuimini.init(mainData);
                            // 展开第一层菜单
                            var firstMenu = $(".layui-left-menu").find("a");
                            $(firstMenu[0]).click();
                        });
                    }
                });


                this.$nextTick(function(){
                    var that = this;
                    $("#topNav").html($("#topNavTpl").html());
                    $("#tabNav").html($("#tabNavTpl").html());
                    // nav必须重新动态加载后渲染才有效
                    // 详见：https://fly.layui.com/jie/18628/
                    element.render('nav');
                    $('#logoutId').click(function () {
                        that.logout()
                    })
                });
            },
            methods: {
                // 创建唯一UUID
                createUUID:function(){
                    var uuid = wp.getValue('zcmg-uuid');
                    // 不存在时生成唯一UUID
                    if(!uuid){
                        var mydate = new Date();
                        uuid = "zcmg"
                            + mydate.getDay()
                            + mydate.getHours()
                            + mydate.getMinutes()
                            + mydate.getSeconds()
                            + mydate.getMilliseconds()
                            + Math.round(Math.random() * 10000);
                        wp.storeValue('zcmg-uuid',uuid);
                    }
                },
                logout: function () {
                    var that = this;
                    wp.removeRefreshToken();
                    wp.removeUser();
                    layer.confirm("确认退出登录?", {title:"提示信息"}, function(index){
                        wp.httpGet({
                            url: wp.url('/wp/ewallet/upms/login/logoutAdmin'),
                            success: function (data) {
                                layer.msg('退出登录成功');
                                wp.removeToken();
                                window.location.href = 'login.html';
                            },
                            failure:function(data){
                                window.location.href = 'login.html';
                            },
                            error:function(){
                                window.location.href = 'login.html';
                            }
                        });
                        layer.close(index);
                    });
                }
            }
        });
    });
</script>
</body>
</html>